import { createRouter, createWebHistory } from 'vue-router'

import { whiteNameList } from './constant'
import { createRouterGuards } from './routerGuards'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/login/index.vue'),
    },
    {
      path: '/dashboard',
      name: 'dashboard',
      component: () => import('@/views/dashboard/index.vue'),
    },
    {
      path: '/warn',
      name: 'warn',
      component: () => import('@/views/warn/index.vue'),
    },
    {
      path: '/warn_detail',
      name: 'warn_detail',
      component: () => import('@/views/warn_detail/index.vue'),
    },
    {
      path: '/my',
      name: 'my',
      component: () => import('@/views/my/index.vue'),
    },
    {
      path: '/report',
      name: 'report',
      component: () => import('@/views/report/index.vue'),
    },
  ],
})

export default router

const setupRouter = (app: App) => {
  createRouterGuards(router, whiteNameList)

  app.use(router)
}

export { setupRouter }
